function simpleUpload(path,resf,num,status){
  var sourceType = status == 'camera' ? 'camera' :'album';
  if(num>1){
    var num=num;
  }else{
    var num = 1;
  }
  var app = getApp();
  var c = require('common.js');
  var cf = require('config.js');
  c.ajax(
    cf.hostapi + '/Im/config',
    {},
    res => {
      var config=res.data.data;
      var Bucket = config.Bucket;
      var Region = config.Region;
      var SecretId = config.SecretId;
      var SecretKey = config.SecretKey;
      var COS = require('cos-wx-sdk-v5.js');
      // 实例COS
      var cos = new COS({
        getAuthorization: function (params, callback) {	//获取签名
          var authorization = COS.getAuthorization({
            SecretId: SecretId,
            SecretKey: SecretKey,
            Method: params.Method,
            Key: params.Key
          });
          callback(authorization);
        }
      });
      // 选择文件

      wx.chooseImage({
        count: num, // 默认9
        sizeType: ['compressed', 'original'], // 可以指定是原图还是压缩图，默认二者都有
        sourceType: [sourceType], // 可以指定来源是相册还是相机，默认二者都有
        success: function (res) {
          console.log(res);
          var imgnum=res.tempFilePaths.length;//计算图片个数
          var dateObj = new Date();
          var timestamp = dateObj.getTime();
          var nowDate = dateObj.toLocaleDateString();
          var tempObj = [];
          var onProgressnum=0;
          // sdk提供的COS上传函数，如果想批量上传，在这里加FOR循环即可。
          for (var i = 0;i< imgnum;i++){
            if (imgnum>1){
              var pathnew = path.replace('.png', i + '.png'); //如果是多张图片 则后边需要添加一个变量 不然会被替换掉
            }else{
              var pathnew = path;
            }
            tempObj.push({ imgLocation: 'https://' + Bucket + '.cos.' + Region + '.myqcloud.com/' + pathnew + '?v=' + Math.random(), dbs: '/' + pathnew }) // 返回上传的绝对URL
            var filePath = res.tempFilePaths[i];
            var upinfo = cos.postObject({
              Bucket: Bucket,  // 存储桶
              Region: Region,  // 地域
              Key: pathnew,
              FilePath: filePath,     // 本地文件临时地址
              onProgress: function (info) {
                onProgressnum++;
                if ((onProgressnum == imgnum)) {  //此处上传图片 上传最后一张图片的时候 调用此函数
                  { resf(tempObj) }
                };
              }
            });     
          }
        
        }
      })



      

    }

  )

}



module.exports = {
  simpleUpload: simpleUpload,
}